package com.leaves.common.operator;

import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.log.Log;
import com.leaves.common.operator.factory.OperatorTaskFactory;

import java.util.Map;
import java.util.TimerTask;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Author Chenweiwei
 * @Date 2022/1/23 16:18
 * @Version 1.0
 */
public class OperatorManager {

    private static final Log log = Log.get();
    /**
     * 异步操作任务调度线程池
     */
    private ScheduledThreadPoolExecutor EXECUTOR = SpringUtil.getBean("scheduledThreadPoolExecutor");
    private OperatorManager() {
    }

    private static final OperatorManager OPERATOR_MANAGER = new OperatorManager();

    public static OperatorManager me() {
        return OPERATOR_MANAGER;
    }

    /**
     * 刷新点赞数
     *
     * @author xuyuxiang
     * @date 2020/4/8 19:19
     */
    public void updateNumberLikes(Long pictureId) {

        TimerTask task = OperatorTaskFactory.createUpdateNumberLikesTask(pictureId);
        //操作延时
        int operateDelayTime = 10;
        EXECUTOR.schedule(task, operateDelayTime, TimeUnit.MILLISECONDS);
    }


}
